<template>
  <div class="total">
      <div class="change" >
     <div v-for="(item,index) in imgs" :key="item.id" class="imgs" @click="itemClick(index,item)">
       <img :src="item.url" alt="1" :class="{active:isActive==index}">
     </div>
      <div class="select">
      <div class="submit" @click="submit()">确认</div>
      <div class="cancel" @click="cancel()">返回</div>
      </div>

  </div>
  </div>
</template>

<script>
import imgList from '@/assets/imgList.js'
export default {
  data(){
    return {
      imgs:imgList,
      isActive:false,
      selectImg:null
    }
  },
  methods:{
    itemClick(index,item){
     this.isActive=index
     this.selectImg=item.url
    },
    cancel(){
      this.$emit('cancel')
    },
    submit(){
      this.$emit('submit',this.selectImg)
    }
  }
}

</script>
<style scoped>
.change{
  padding: 50px 0;
  margin-top: 30px;
  height: 300px;
  width: 600px;
  background-color: white;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  display: flex;
  justify-content:flex-start;
  flex-wrap: wrap;
  overflow: auto;
}
 .imgs{
   width: 25%;
 }
 .imgs img{
   border-radius: 20px;
   width: 100px;
   height: 100px;
 }
 .active {
    border: 1px solid green;
 }
 .select {
  padding: 20px;
   display: flex;
   margin: 0 auto;

 }
 .select div{
   margin-left: 10px;
   flex: 1;
  background-color: black;
  color: white;
  height: 50px;
  width: 150px;
  line-height: 50px;
  text-align: center;
  border-radius: 20px;
 }
</style>